import axios from 'axios';

/**
 * 方法一: 直接拿返回结果的，没有loading层需要判断的；
*/
const Axios = (url, params, callback) => {
    axios({
        url: url,
        method: 'post',
        responseType: 'json',
        data: JSON.stringify(params),
        headers: {'Content-Type': 'application/json; charset=utf-8'}
    })
    .then((response) => {
        const result = response.data;
        if (result.errorCode == '00') {
           callback(result.result);
        } else {
            Message({
                type: 'warning',
                message: result.message
            });
        }
    })
    .catch((error) => {
        Message({
            type: 'error',
            message: error
        });
    });
};

export default Axio